package com.taocore.top.title.service;

import com.taocore.top.title.domain.DiagnoseResult;

public class WhiteSpacesChecker implements TitleChecker{

	public static final int SPACES_MAX = 5;
	@Override
	public DiagnoseResult check(String title) {
		int count = 0;
		for (int i = 0, n = title.length(); i < n; i++)
		{
			char c = title.charAt(i);
			if (Character.isWhitespace(c))
			{
				++count;
			}
		}
		if (count > SPACES_MAX)
		{
			DiagnoseResult result = new DiagnoseResult();
			result.setMsg("标题包含太多空格，建议删除不必要的空格。为保证可读性不得不使用的空格，建议以“/”代替。");
			return result;
		}
		return null;
	}

}
